package com.ruoyi.web.controller.saas;

import com.bonuo.saas.domain.TaskDelivery;
import com.bonuo.saas.service.TaskDeliveryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/saas/taskDelivery")
@Api(tags = "任务单交付管理")
public class TaskDeliveryController extends BaseController {

    @Autowired
    private TaskDeliveryService taskDeliveryService;

    @ApiOperation(value = "查询任务单交付信息",httpMethod = "GET")
    @GetMapping("/list")
    public TableDataInfo selectTaskDeliveryList(TaskDelivery taskDelivery, Integer pageNum, Integer pageSize){
        if(pageNum != null && pageSize != null){
            startPage();
        }
        List<TaskDelivery> list = taskDeliveryService.selectTaskDeliveryList(taskDelivery);
        return getDataTable(list);
    }

    @ApiOperation(value = "添加任务单交付信息",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TaskDelivery taskDelivery){
        return toAjax(taskDeliveryService.insertTaskDelivery(taskDelivery));
    }

    @ApiOperation(value = "修改任务单交付信息",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody TaskDelivery taskDelivery){
        return toAjax(taskDeliveryService.updateTaskDelivery(taskDelivery));
    }

    @ApiOperation(value = "删除任务单交付信息",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        return toAjax(taskDeliveryService.deleteTaskDeliveryById(id));
    }

}
